#ifndef __KPF_SINGLETON_H__
#define __KPF_SINGLETON_H__

#include "KPF_Guard.h"

#include "KPF_Object.h"

template < class T >
class KPF_Singleton : public KPF_Object
{
public:
	static T &instance( void )
	{
		return getInstance(  );
	}
	

protected:
	static T&getInstance( void )
	{
		static T *pInstance = NULL;
		
		if ( !pInstance )
		{
			static KPF_Locker Locker;
			
			KPF_Guard guard(Locker);
			
			if ( !pInstance )
			{
				pInstance = new T(  );
			}
		}
		
		return *pInstance;
	}
private:

};

#endif
